
package com.infindo.frame.data;



public class ThreadManager{
	/** Background worker thread(s) used for: http req */
	AsyncProcessor async1;

	/** Background worker thread(s) used for: decoding image */
	AsyncProcessor async2;

	public ThreadManager()
	{
		async2 = new AsyncProcessor(4);//image
		async1 = new AsyncProcessor(2);//text
	}
	
	public void netProcess(DataHandler handler)
	{
		if(handler.isHandlerImage())
		{
			async2.enqueueJob(handler);
		}
		else
		{
			async1.enqueueJob(handler);
		}
	}
	
	public boolean workerCancelHandler(int dataHandlerNo)
	{
		if(async1.asynCancelHandler(dataHandlerNo))
		{
			return true;
		}
		if(async2.asynCancelHandler(dataHandlerNo))
		{
			return true;
		}
		return false;
	}
}
